﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace lyh.FG2JiaYaZhanDemo
{
    public partial class MeterControl : UserControl
    {
        public MeterControl()
        {
            InitializeComponent();
        }


        private string meterName="1#出水管温度";
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("文字描述")]
        public string MeterName
        {
            get { return meterName; }
            set
            {
                meterName = value;
                this.label2.Text = meterName;
            }
        }

        private string unit = " ℃";
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("单位")]
        public string Unit
        {
            get { return unit; }
            set
            {
                unit = value;
                this.label1.Text = meterValue.ToString("f2") + " " + unit;
            }
        }
        

        private float  meterValue=0.0f;
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("当前值")]
        public float  MeterValue
        {
            get { return meterValue; }
            set
            {
                if (meterValue != value)
                {
                    meterValue = value;
                    this.uiMeter1.Value = meterValue;
                    this.label1.Text = value.ToString("f2") + " " + unit;
                }
            }
        }

        private float minValue = 0.0f;
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("最小值")]
        public float MinValue
        {
            get { return minValue; }
            set
            {
                minValue = value;
                this.uiMeter1.MinValue = minValue;
            }
        }


        private float maxValue = 100.0f;
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("最大值")]
        public float MaxValue
        {
            get { return maxValue; }
            set
            {
                maxValue = value;
                this.uiMeter1.MaxValue = maxValue;
            }
        }

        private Color rectColor = Color.FromArgb(80, 160, 255);
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("边框颜色")]
        public Color RectColor
        {
            get { return rectColor; }
            set
            {
                rectColor = value;
                this.uiMeter1.RectColor = rectColor;
            }
        }


        private Color needleColor = Color.Red;
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("指针颜色")]
        public Color NeedleColor
        {
            get { return needleColor; }
            set
            {
                needleColor = value;
                this.uiMeter1.NeedleColor = needleColor;
            }
        }

        private Color foreColor = Color.WhiteSmoke;
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("meter文字颜色")]
        public Color ForeColor
        {
            get { return foreColor; }
            set
            {
                foreColor = value;
                this.uiMeter1.ForeColor = foreColor;             
            }
        }

        private int scaleDivisions = 10;
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("刻度数量")]
        public int ScaleDivisions
        {
            get { return scaleDivisions; }
            set
            {
                scaleDivisions = value;
                this.uiMeter1.ScaleDivisions = scaleDivisions;
            }
        }


        private int scaleSubDivisions = 5;
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("刻度分段数量")]
        public int ScaleSubDivisions
        {
            get { return scaleSubDivisions; }
            set
            {
                scaleSubDivisions = value;
                this.uiMeter1.ScaleSubDivisions = scaleSubDivisions;
            }
        }
    }
} 

